package com.atguigu.spzx.manager.config;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
@ConfigurationProperties(prefix = "spzx.minio")
public class MinioProperties implements InitializingBean {
    private String endpoint;//: "http://192.168.1.170:9000"
    private String accessKey;// "admin"
    private String secretKey;//: "admin123456"
    private String bucket;// "spzx"

    //定义静态属性：  类加载时就会被初始化 ， 可以在容器给当前组件类属性值设置成功后 将成员属性值设置给静态属性
    public static  String ENDPOINT;//: "http://192.168.1.170:9000"
    public static  String ACCESS_KEY;// "admin"
    public static   String SECRET_KEY;//: "admin123456"
    public static  String BUCKET;// "spzx"
    //容器在初始化当前组件类以后 自动调用该方法  springbean的生命周期方法
    @Override
    public void afterPropertiesSet() throws Exception {
        ENDPOINT = this.endpoint;
        ACCESS_KEY = this.accessKey;
        SECRET_KEY = this.secretKey;
        BUCKET = this.bucket;
    }
}
